<?php

class productPageActions extends myFrontendAction
{
    public function preExecute()
    {
        parent::preExecute();
        
        $this->model = new Product();
    }
    
    
    public function executeIndex(sfRequest $request)
    {
        $this->product   = $this->getRoute()->getProductObject();
        $this->files     = $this->model->getProductFiles($this->getUser()->getCulture(), $this->product->getId());
        $this->pictures  = $this->model->getProductPics($this->getUser()->getCulture(), $this->product->getId());
        $this->connected = $this->model->getConnectedProducts($this->product, $this->getUser());
        $this->c_links   = LinkGen::getInstance(LinkGen::PRODUCT)->collectionLinks($this->connected);
        
        // Generate files extension
        $files = array();
        
        foreach($this->files as $j => $file)
        {
            $extension = explode('.', $file['original_filename']);
            
            $files[$j] = $file;
            $files[$j]['extension'] = strtoupper(end($extension));
        }
        
        $this->files = $files;
    }
};